<%@page import="com.award.model.User"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
User user = (User)session.getAttribute("user");
%>

<!DOCTYPE html>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'updateUserInformation.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="./css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="./css/flat-ui.min.css" rel="stylesheet">
    <link href="./css/style.min.css" rel="stylesheet">
	<script src="./js/registerCheck.js"></script>
	<script type="text/javascript">
		function formCheck(){
			var usernameTip=$("#usernameTip").text();
			var nameTip=$("#nameTip").text();
			var passwordTip=$("#passwordTip").text(); 
			var passwordRepeatTip=$("#passwordRepeatTip").text();
			var addressTip=$("#addressTip").text();
			  
			  if((usernameTip=="√ 该用户名可以注册，输入正确" || usernameTip=="")
				   &&(nameTip=="√ 姓名输入正确" || nameTip=="")
				&&passwordTip=="√ 密码合格" 
				&&passwordRepeatTip=="√ 密码输入一致"
				&&(addressTip=="√ 地址填写正确"|| addressTip=="") )
			  {
				  return true;
			  }else{
				  return false;
			  }
		}
	</script>
  </head>
  
  <body>
<div style="height:10px;"><span class="glyphicon glyphicon-home"><u>返回首页</u></a></div>
		<div style="margin: 0 auto;background-color: #ffffff">
<div id="profile" class="container" style="max-width: 500px;">
<h3 style="text-align: center">修改个人信息</h3>
        <form method="post" action="servlet/updateUserInformation" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return formCheck()">
            <div class="form-group">
                您的昵称<input name="username" id="username" type="text" class="form-control" value="<%=user.getUsername() %>" onchange="checkusername()" ><span id="usernameTip"></span><br>
        您的真实姓名*（必填）<input name="name" id="name" type="text" class="form-control" value="<%=(user.getName()==null)?"":user.getName() %>" onBlur="checkname()"><span id="nameTip"></span><br>       
        
      <img src="<%=user.getUserImgURL() %>" style="height:200px;width:200px;"/><span>图片大小不能超过2Mb</span><Br>
                修改头像 <input type="file" id="updateURL" name="updateURL"><br>       
		      密码<input id="password" name="password"
			type="password" class="form-control" placeholder="至少6位字符" onBlur="checkpassword()"><span id="passwordTip"></span><br>
			 确认密码<input id="passwordRepeat" name="passwordRepeat"
			type="password" class="form-control" placeholder="输入与上相同密码" onBlur="checkpasswrodb()"><span id="passwordRepeatTip"></span>
			<br>
                 地址*（必填）
       <%if(user.getAddress().equals("")){ %>
       <input type="text" name="address" id="address" class="form-control" placeholder="*请填写地址*" onblur="addCheck()" /><span id="addressTip"></span>
       <%}else{ %>
       <input type="text" name="address" id="address" class="form-control" value="<%= user.getAddress() %>" onblur="addCheck()"/><span id="addressTip"></span>
       <%} %><br>
       <input type="submit" class="sbtn sbtn-red" style="width: 100%;" value="提交"/>
            </div>
       
        </form>
</div>
</div>
<footer>
    <div>
        Copyright &copy; 2017
    </div>
</footer>

<script src="./js/jquery.min.js"></script>
<script src="./js/flat-ui.min.js"></script>
<script src="./js/script.js"></script>
</body>
</html>
